ALMaSS  1.0
The Animal, Landscape and Man Simulation System
TPredator_Population_Manager Class Reference

The class to handle all predator population related matters. More...

#include <Predators.h>

Inheritance diagram for TPredator_Population_Manager:
Population_Manager

Public Member Functions

virtual void Run (int)
 
bool InOtherTerritory (unsigned sp, int p_x, int p_y, TPredator *p_Pred)
 
 TPredator_Population_Manager (Landscape *L, Vole_Population_Manager *VPM)
 
virtual ~TPredator_Population_Manager (void)
 
void CreateObjects (int ob_type, TAnimal *pvo, struct_Predator *data, int number)
 
void inc_inds (unsigned list)
 
void dec_inds (unsigned list)
 
unsigned supply_no_inds (unsigned list)
 
- Public Member Functions inherited from Population_Manager
 Population_Manager (Landscape *L)
 
virtual ~Population_Manager (void)
 
void SetNoProbes (int a_pn)
 
unsigned GetLiveArraySize (int a_listindex)
 Gets the number of 'live' objects for a list index in the TheArray. More...
 
void IncLiveArraySize (int a_listindex)
 Increments the number of 'live' objects for a list index in the TheArray. More...
 
virtual void Catastrophe (int)
 
unsigned int FarmAnimalCensus (unsigned int a_farm, unsigned int a_typeofanimal)
 
char * SpeciesSpecificReporting (int a_species, int a_time)
 
char * ProbeReport (int a_time)
 
char * ProbeReportTimed (int a_time)
 
void ImpactProbeReport (int a_Time)
 
bool BeginningOfMonth ()
 
void LOG (const char *fname)
 
int SupplyStepSize ()
 
int SupplySimW ()
 
int SupplySimH ()
 
virtual float Probe (int ListIndex, probe_data *p_TheProbe)
 
virtual void ImpactedProbe ()
 
int SupplyListNameLength ()
 
TAnimalSupplyAnimalPtr (int a_index, int a_animal)
 Returns the pointer indexed by a_index and a_animal. Note NO RANGE CHECK. More...
 
unsigned SupplyListIndexSize ()
 
unsigned SupplyListSize (unsigned listindex)
 
bool CheckXY (int l, int i)
 Debug method to test for out of bounds coordinates. More...
 
const char * SupplyListName (int i)
 
bool IsLast (unsigned listindex)
 
int SupplyState (unsigned listindex, unsigned j)
 
virtual void SupplyLocXY (unsigned listindex, unsigned j, int &x, int &y)
 
const char * SupplyStateNames (int i)
 
unsigned SupplyStateNamesLength ()
 
virtual void DisplayLocations ()
 
int ProbeFileInput (char *p_Filename, int p_ProbeNo)
 
TAnimalFindClosest (int x, int y, unsigned Type)
 
bool OpenTheRipleysOutputProbe (string a_NWordFilename)
 
void OpenTheAOROutputProbe (string a_AORFilename)
 
bool OpenTheMonthlyRipleysOutputProbe ()
 
bool OpenTheReallyBigProbe ()
 
virtual void TheAOROutputProbe ()
 
virtual void TheRipleysOutputProbe (FILE *a_prb)
 
virtual void TheReallyBigOutputProbe ()
 
void CloseTheMonthlyRipleysOutputProbe ()
 
TTypesOfPopulation GetPopulationType ()
 
int GetSeasonNumber ()
 Get the season number. More...
 
void LamdaDeath (int x, int y)
 
void LamdaBirth (int x, int y)
 
void LamdaBirth (int x, int y, int z)
 
void LamdaClear ()
 
void LamdaDumpOutput ()
 
virtual int SupplyPegPosx (int)
 
virtual int SupplyPegPosy (int)
 
virtual int SupplyCovPosx (int)
 
virtual int SupplyCovPosy (int)
 
virtual bool OpenTheFledgelingProbe ()
 
virtual bool OpenTheBreedingPairsProbe ()
 
virtual bool OpenTheBreedingSuccessProbe ()
 
virtual void BreedingPairsOutput (int)
 
virtual int TheBreedingFemalesProbe (int)
 
virtual int TheFledgelingProbe ()
 
virtual void BreedingSuccessProbeOutput (double, int, int, int, int, int, int, int)
 
virtual int TheBreedingSuccessProbe (int &, int &, int &, int &, int &, int &)
 
virtual void FledgelingProbeOutput (int, int)
 
virtual void TheGeneticProbe (unsigned, int, unsigned &)
 
virtual void GeneticsResultsOutput (FILE *, unsigned)
 

Protected Member Functions

virtual bool StepFinished ()
 Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour. More...
 
virtual void DoFirst ()
 
virtual void DoBefore ()
 
virtual void DoAfter ()
 
virtual void DoLast ()
 
void CloseTheReallyBigOutputProbe ()
 
virtual void CloseTheRipleysOutputProbe ()
 
void PredSampleFile ()
 
void PredAutumnSample ()
 
void PredSpringSample ()
 
void PredSpringAutumnSample ()
 
- Protected Member Functions inherited from Population_Manager
virtual void DoAlmostLast ()
 
void EmptyTheArray ()
 Removes all objects from the TheArray by deleting them and clearing TheArray. More...
 
void SortX (unsigned Type)
 
void SortXIndex (unsigned Type)
 
void SortY (unsigned Type)
 
void SortState (unsigned Type)
 
void SortStateR (unsigned Type)
 
unsigned PartitionLiveDead (unsigned Type)
 
void Shuffle_or_Sort (unsigned Type)
 
void Shuffle (unsigned Type)
 
virtual void Catastrophe ()
 

Protected Attributes

Vole_Population_Managerm_Prey
 
unsigned NoPredatorTypes
 
unsigned m_no_individuals [2]
 
- Protected Attributes inherited from Population_Manager
vector< unsigned > m_LiveArraySize
 
int m_NoProbes
 
AOR_Probem_AOR_Probe
 
FILE * m_GeneticsFile
 
FILE * m_AlleleFreqsFile
 
FILE * m_EasyPopRes
 
const char * StateNames [100]
 
int m_catastrophestartyear
 
int m_StepSize
 
vector< TListOfAnimalsTheArray
 
unsigned StateNamesLength
 
const char * m_ListNames [32]
 
unsigned m_ListNameLength
 
FILE * TestFile
 
FILE * TestFile2
 
unsigned BeforeStepActions [12]
 
int m_SeasonNumber
 Holds the season number. Used when running goose and hunter sims. More...
 
TTypesOfPopulation m_population_type
 
ofstream * AOROutputPrb
 
FILE * RipleysOutputPrb
 
FILE * RipleysOutputPrb1
 
FILE * RipleysOutputPrb2
 
FILE * RipleysOutputPrb3
 
FILE * RipleysOutputPrb4
 
FILE * RipleysOutputPrb5
 
FILE * RipleysOutputPrb6
 
FILE * RipleysOutputPrb7
 
FILE * RipleysOutputPrb8
 
FILE * RipleysOutputPrb9
 
FILE * RipleysOutputPrb10
 
FILE * RipleysOutputPrb11
 
FILE * RipleysOutputPrb12
 
FILE * ReallyBigOutputPrb
 
long int lamdagrid [2][257][257]
 

Additional Inherited Members

- Public Attributes inherited from Population_Manager
int IndexArrayX [5][10000]
 
probe_dataTheProbe [100]
 
int SimH
 
int SimW
 
unsigned SimHH
 
unsigned SimWH
 
char m_SimulationName [255]
 
bool ProbesSet
 
Landscapem_TheLandscape
 

Detailed Description

The class to handle all predator population related matters.

Constructor & Destructor Documentation

◆ TPredator_Population_Manager()

TPredator_Population_Manager::TPredator_Population_Manager ( Landscape L,
Vole_Population_Manager VPM 
)
92 {
93  // Constants for the predator species
102  // Must now create as many array elements as we have predator types
103  // two lists are needed so need to remove 8 of the ten default arrays
104  // Weasels and Owls
105  for (int i=0; i<8; i++)
106  {
107  TheArray.pop_back();
108  }
109  // Remember the prey
110  m_Prey=VPM;
113  // Create some weasels and owls
114  struct_Predator* sp;
115  sp = new struct_Predator;
116  sp->PM = this;
117  sp->L = m_TheLandscape;
119  for (int i=0; i<weasel_StartingNo; i++)
120  {
121  sp->x = random(SimW);
122  sp->y = random(SimH);
123  CreateObjects(0,NULL,sp,1); // 0 = weasel
124  }
125  for (int i=0; i<owl_StartingNo; i++)
126  {
127  sp->x = random(SimW);
128  sp->y = random(SimH);
129  CreateObjects(1,NULL,sp,1); // 1 = Owl
130  }
131  delete sp;
134 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
@ TOP_Predators
Definition: PopulationManager.h:76
static CfgInt cfg_owl_breed_threshold("OWL_BT", CFG_CUSTOM, 5000000)
int weasel_death_threshold
Definition: Predators.cpp:74
static CfgInt cfg_owl_breed_day("OWL_BD", CFG_CUSTOM, 120)
static CfgInt cfg_owl_death_threshold("OWL_DT", CFG_CUSTOM,-1)
#define WEASEL
Definition: Predators.cpp:48
static CfgInt cfg_weasel_death_threshold("WEASEL_DT", CFG_CUSTOM, 10)
static CfgInt cfg_weasel_breed_day("WEASEL_BD", CFG_CUSTOM, 115)
int weasel_StartingNo
Definition: Predators.cpp:79
int weasel_breed_threshold
Definition: Predators.cpp:72
static CfgInt cfg_weasel_StartingNo("WEASEL_START_NO", CFG_CUSTOM, 0)
static CfgInt cfg_owl_StartingNo("OWL_START_NO", CFG_CUSTOM, 0)
static CfgInt cfg_weasel_breed_threshold("WEASEL_BT", CFG_CUSTOM, 5)
#define OWL
Definition: Predators.cpp:49
int owl_death_threshold
Definition: Predators.cpp:75
int owl_breed_threshold
Definition: Predators.cpp:73
int owl_breed_day
Definition: Predators.cpp:77
int owl_StartingNo
Definition: Predators.cpp:78
int weasel_breed_day
Definition: Predators.cpp:76
int value(void)
Definition: configurator.h:98
FILE * ReallyBigOutputPrb
Definition: PopulationManager.h:595
int SimH
Definition: PopulationManager.h:511
FILE * RipleysOutputPrb
Definition: PopulationManager.h:582
Population_Manager(Landscape *L)
Definition: PopulationManager.cpp:221
TTypesOfPopulation m_population_type
Definition: PopulationManager.h:580
vector< TListOfAnimals > TheArray
Definition: PopulationManager.h:534
int SimW
Definition: PopulationManager.h:511
Landscape * m_TheLandscape
Definition: PopulationManager.h:515
unsigned m_no_individuals[2]
Definition: Predators.h:163
Vole_Population_Manager * m_Prey
Definition: Predators.h:161
void CreateObjects(int ob_type, TAnimal *pvo, struct_Predator *data, int number)
Definition: Predators.cpp:137
Used for creation of a new predator object.
Definition: Predators.h:66
Landscape * L
Definition: Predators.h:71
TPredator_Population_Manager * PM
Definition: Predators.h:72
int x
Definition: Predators.h:68
int y
Definition: Predators.h:69

References cfg_owl_breed_day, cfg_owl_breed_threshold, cfg_owl_death_threshold, cfg_owl_StartingNo, cfg_weasel_breed_day, cfg_weasel_breed_threshold, cfg_weasel_death_threshold, cfg_weasel_StartingNo, CreateObjects(), struct_Predator::L, m_no_individuals, Population_Manager::m_population_type, m_Prey, Population_Manager::m_TheLandscape, OWL, owl_breed_day, owl_breed_threshold, owl_death_threshold, owl_StartingNo, struct_Predator::PM, random(), Population_Manager::ReallyBigOutputPrb, Population_Manager::RipleysOutputPrb, Population_Manager::SimH, Population_Manager::SimW, Population_Manager::TheArray, TOP_Predators, CfgInt::value(), WEASEL, weasel_breed_day, weasel_breed_threshold, weasel_death_threshold, weasel_StartingNo, struct_Predator::x, and struct_Predator::y.

◆ ~TPredator_Population_Manager()

TPredator_Population_Manager::~TPredator_Population_Manager ( void  )
virtual
84 {
85  // Should all be done by the Population_Manager destructor
86 }

Member Function Documentation

◆ CloseTheReallyBigOutputProbe()

void TPredator_Population_Manager::CloseTheReallyBigOutputProbe ( )
inlineprotectedvirtual

close the probe

Reimplemented from Population_Manager.

171 {}; // This will always be done by the main population manager

◆ CloseTheRipleysOutputProbe()

virtual void TPredator_Population_Manager::CloseTheRipleysOutputProbe ( )
inlineprotectedvirtual

close the probe

Reimplemented from Population_Manager.

172 {}; // This will always be done by the main population manager

◆ CreateObjects()

void TPredator_Population_Manager::CreateObjects ( int  ob_type,
TAnimal pvo,
struct_Predator data,
int  number 
)
139 {
140  Weasel* new_Weasel;
141  Owl* new_Owl;
142  for (int i=0; i<number; i++)
143  {
144  if (ob_type == WEASEL) // Weasel
145  {
146  new_Weasel = new Weasel(m_Prey,data->x, data->y, data->L, data->PM);
147  TheArray[ob_type].push_back(new_Weasel);
148  inc_inds(WEASEL);
149  }
150  if (ob_type == OWL) // Owl
151  {
152  new_Owl = new Owl(m_Prey,data->x, data->y, data->L, data->PM);
153  TheArray[ob_type].push_back(new_Owl);
154  inc_inds(OWL);
155  }
156  }
157 }
The Owl class is one of two current implementations of TPredator.
Definition: Predators.h:209
void inc_inds(unsigned list)
Definition: Predators.h:155
The Weasel class is one of two current implementations of TPredator.
Definition: Predators.h:188

References inc_inds(), struct_Predator::L, m_Prey, OWL, struct_Predator::PM, Population_Manager::TheArray, WEASEL, struct_Predator::x, and struct_Predator::y.

Referenced by Weasel::BeginStep(), Owl::BeginStep(), and TPredator_Population_Manager().

◆ dec_inds()

void TPredator_Population_Manager::dec_inds ( unsigned  list)
inline
156 {m_no_individuals[list]--;}

References m_no_individuals.

Referenced by Weasel::BeginStep(), and Owl::BeginStep().

◆ DoAfter()

virtual void TPredator_Population_Manager::DoAfter ( )
inlineprotectedvirtual

Can be used in descendent classes

Reimplemented from Population_Manager.

169 {}

Referenced by Run().

◆ DoBefore()

virtual void TPredator_Population_Manager::DoBefore ( void  )
inlineprotectedvirtual

Can be used in descendent classes

Reimplemented from Population_Manager.

168 {}

Referenced by Run().

◆ DoFirst()

virtual void TPredator_Population_Manager::DoFirst ( void  )
inlineprotectedvirtual

Can be used in descendent classes

Reimplemented from Population_Manager.

167 {}

Referenced by Run().

◆ DoLast()

virtual void TPredator_Population_Manager::DoLast ( void  )
inlineprotectedvirtual

Collects some data to describe the number of animals in each state at the end of the day

Reimplemented from Population_Manager.

170 {}

Referenced by Run().

◆ inc_inds()

void TPredator_Population_Manager::inc_inds ( unsigned  list)
inline
155 {m_no_individuals[list]++;}

References m_no_individuals.

Referenced by CreateObjects().

◆ InOtherTerritory()

bool TPredator_Population_Manager::InOtherTerritory ( unsigned  sp,
int  p_x,
int  p_y,
TPredator p_Pred 
)
673 {
674  // Go through sp species and see if a territory at x,y will overlap with
675  // theirs
676  for (unsigned i=0; i<TheArray[sp].size(); i++)
677  {
678  TPredator* APredator=(TPredator *)TheArray[sp][i];
679  if (APredator->OverlapMyTerritory(x,y))
680  {
681  if (APredator!=p_Pred) return true;
682  }
683  }
684  return false;
685 }
The base class for predators encompsassing all their general behaviours.
Definition: Predators.h:88
bool OverlapMyTerritory(unsigned x, unsigned y)
Definition: Predators.cpp:770

References TPredator::OverlapMyTerritory(), and Population_Manager::TheArray.

Referenced by TPredator::st_Dispersal().

◆ PredAutumnSample()

void TPredator_Population_Manager::PredAutumnSample ( )
protected
361 {
362  int today = m_TheLandscape->SupplyDayInYear();
363  int year = m_TheLandscape->SupplyYearNumber();
364 
366  FILE* pref=fopen("PredAutumnOutput.txt","a");
367  if (pref == NULL) {
368  m_TheLandscape->Warn("TPredator_Population_Manager::PredAutumnSample","Could Not Open PredAutumnOutput.txt File");
369  exit(0);
370  }
371 
372  unsigned int SizeWeasel = (unsigned int) TheArray[0].size();
373  unsigned int SizeOwl = (unsigned int) TheArray[1].size();
374  unsigned int TotalSize = SizeWeasel+SizeOwl;
375 
376  fprintf(pref,"%d\t", year);
377  fprintf(pref,"%d\t", today);
378  fprintf(pref,"%d\t", SizeWeasel);
379  fprintf(pref,"%d\t", SizeOwl);
380  fprintf(pref,"%d\t", TotalSize);
381  fprintf(pref,"\n");
382 
383  fclose(pref);
384  }
385 
386  else if (cfg_weasel_StartingNo.value()> 0){
387  unsigned int SizeWeasel = (unsigned int) TheArray[0].size();
388 
389  FILE* pref = fopen("PredAutumnOutput.txt","a");
390  if (pref == NULL) {
391  m_TheLandscape->Warn("TPredator_Population_Manager::PredAutumnSample","Could Not Open PredAutumnOutput.txt File");
392  exit(0);
393  }
394  fprintf(pref,"%d\t", year);
395  fprintf(pref,"%d\t", today);
396  fprintf(pref,"%d\t", SizeWeasel);
397  fprintf(pref,"%d\t", 0);
398  fprintf(pref,"%d\t", SizeWeasel);
399  fprintf(pref,"\n");
400 
401  fclose(pref);
402  }
403 
404  else if (cfg_owl_StartingNo.value()> 0) {
405  unsigned int SizeOwl = (unsigned int)TheArray[1].size();
406 
407  FILE* pref = fopen("PredAutumnOutput.txt","a");
408  if (pref == NULL) {
409  m_TheLandscape->Warn("TPredator_Population_Manager::PredAutumnSample","Could Not Open PredAutumnOutput.txt File");
410  exit(0);
411  }
412  fprintf(pref,"%d\t", year);
413  fprintf(pref,"%d\t", today);
414  fprintf(pref,"%d\t", 0);
415  fprintf(pref,"%d\t", SizeOwl);
416  fprintf(pref,"%d\t", SizeOwl);
417  fprintf(pref,"\n");
418 
419  fclose(pref);
420  }
421 }
int SupplyYearNumber(void)
Definition: landscape.h:1616
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
int SupplyDayInYear(void)
Definition: landscape.h:1596

References cfg_owl_StartingNo, cfg_weasel_StartingNo, Population_Manager::m_TheLandscape, Landscape::SupplyDayInYear(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, CfgInt::value(), and Landscape::Warn().

Referenced by Run().

◆ PredSampleFile()

void TPredator_Population_Manager::PredSampleFile ( )
protected
161  {
162 
163  int today = m_TheLandscape->SupplyDayInYear();
164  int year = m_TheLandscape->SupplyYearNumber();
165  int month = m_TheLandscape->SupplyMonth();
166  int dayinMo = m_TheLandscape->SupplyDayInMonth();
167 
169 
170  FILE* pref=fopen("PredSampleData.txt","a");
171  if (pref == NULL) {
172  m_TheLandscape->Warn("TPredator_Population_Manager::PredSampleFile","Could Not Open PredSampleData.txt File");
173  exit(0);
174  }
175 
176  Weasel* Wp;
177  unsigned int SizeWeasel = (unsigned int) TheArray[0].size();
178  Owl* Op;
179  unsigned int SizeOwl = (unsigned int) TheArray[1].size();
180  unsigned int TotalSize = SizeWeasel+SizeOwl;
181 
184  fprintf(pref,"%d\t %d\t %d\t %d\t %u\t %u\n", 0,w ,0, h, SizeWeasel, TotalSize);
185 
186  for (unsigned i=0; i<SizeWeasel; i++){
187 
188  Wp=dynamic_cast<Weasel*>(TheArray[0][i]);
189  int Wx = Wp->Supply_m_Location_x();
190  int Wy = Wp->Supply_m_Location_y();
191  int Wpoly = m_TheLandscape->SupplyPolyRef(Wx, Wy);
192  int Wele = m_TheLandscape->SupplyElementType(Wpoly);
193  int Wveg = m_TheLandscape->SupplyVegType(Wpoly);
194 
195  unsigned Wspecies = Wp->SupplySpeciesID();
196  int kill = Wp->SupplyKill();
197  int KillEff = Wp->SupplyKillEff();
198  int Terr = Wp->SupplyTerr();
199  int HomeR = Wp->SupplyHomeRange();
200 
201  fprintf(pref,"%d\t",year);
202  fprintf(pref,"%d\t",month);
203  fprintf(pref,"%d\t",dayinMo);
204  fprintf(pref,"%d\t",today);
205 
206  fprintf(pref,"%d\t",Wspecies);
207  fprintf(pref,"%d\t",kill);
208  fprintf(pref,"%d\t",KillEff);
209  fprintf(pref,"%d\t",Terr);
210  fprintf(pref,"%d\t",HomeR);
211 
212  fprintf(pref,"%d\t",Wx);
213  fprintf(pref,"%d\t",Wy);
214  fprintf(pref,"%d\t",Wpoly);
215  fprintf(pref,"%d\t",Wele);
216  fprintf(pref,"%d\t",Wveg);
217  fprintf(pref,"\n");
218  }
219 
220  fprintf(pref,"%d\t %d\t %d\t %d\t %u\t %u\n", 0,w ,0, h, SizeOwl, TotalSize);
221 
222  for (unsigned i = 0; i < SizeOwl; i++){
223  Op=dynamic_cast<Owl*>(TheArray[1][i]);
224  int Ox = Op->Supply_m_Location_x();
225  int Oy = Op->Supply_m_Location_y();
226  int Opoly = m_TheLandscape->SupplyPolyRef(Ox, Oy);
227  int Oele = m_TheLandscape->SupplyElementType(Opoly);
228  int Oveg = m_TheLandscape->SupplyVegType(Opoly);
229 
230  int species = Op->SupplySpeciesID();
231  int kill = Op->SupplyKill();
232  int KillEff = Op->SupplyKillEff();
233  int Terr = Op->SupplyTerr();
234  int HomeR = Op->SupplyHomeRange();
235 
236  fprintf(pref,"%d\t",year);
237  fprintf(pref,"%d\t",month);
238  fprintf(pref,"%d\t",dayinMo);
239  fprintf(pref,"%d\t",today);
240 
241  fprintf(pref,"%d\t",species);
242  fprintf(pref,"%d\t",kill);
243  fprintf(pref,"%d\t",KillEff);
244  fprintf(pref,"%d\t",Terr);
245  fprintf(pref,"%d\t",HomeR);
246 
247  fprintf(pref,"%d\t",Ox);
248  fprintf(pref,"%d\t",Oy);
249  fprintf(pref,"%d\t",Opoly);
250  fprintf(pref,"%d\t",Oele);
251  fprintf(pref,"%d\t",Oveg);
252  fprintf(pref,"\n");
253  }
254  fclose(pref);
255  }
256 
257  else if (cfg_weasel_StartingNo.value()> 0){
258 
259  FILE* pref=fopen("PredSampleData.txt","a");
260  if (pref == NULL) {
261  m_TheLandscape->Warn("TPredator_Population_Manager::PredSampleFile","Could Not Open PredSampleData.txt File");
262  exit(0);
263  }
264 
265  Weasel* Wp;
266  unsigned int SizeWeasel = (unsigned int) TheArray[0].size();
267  unsigned int TotalSize = (unsigned int) SizeWeasel;
268 
271  fprintf(pref,"%d\t %d\t %d\t %d\t %u\t %u\n", 0,w ,0, h, SizeWeasel, TotalSize);
272 
273  for (unsigned i = 0; i < SizeWeasel; i++){
274  Wp=dynamic_cast<Weasel*>(TheArray[0][i]);
275  int Wx = Wp->Supply_m_Location_x();
276  int Wy = Wp->Supply_m_Location_y();
277 
278  int Wpoly = m_TheLandscape->SupplyPolyRef(Wx, Wy);
279  int Wele = m_TheLandscape->SupplyElementType(Wpoly);
280  int Wveg = m_TheLandscape->SupplyVegType(Wpoly);
281 
282  int species = Wp->SupplySpeciesID();
283  int kill = Wp->SupplyKill();
284  int KillEff = Wp->SupplyKillEff();
285  int Terr = Wp->SupplyTerr();
286  int HomeR = Wp->SupplyHomeRange();
287 
288  fprintf(pref,"%d\t",year);
289  fprintf(pref,"%d\t",month);
290  fprintf(pref,"%d\t",dayinMo);
291  fprintf(pref,"%d\t",today);
292 
293  fprintf(pref,"%d\t",species);
294  fprintf(pref,"%d\t",kill);
295  fprintf(pref,"%d\t",KillEff);
296  fprintf(pref,"%d\t",Terr);
297  fprintf(pref,"%d\t",HomeR);
298 
299  fprintf(pref,"%d\t",Wx);
300  fprintf(pref,"%d\t",Wy);
301  fprintf(pref,"%d\t",Wpoly);
302  fprintf(pref,"%d\t",Wele);
303  fprintf(pref,"%d\t",Wveg);
304  fprintf(pref,"\n");
305  }
306  fclose(pref);
307  }
308 
309  else if (cfg_owl_StartingNo.value()> 0) {
310 
311  FILE* pref=fopen("PredSampleData.txt","a");
312  if (pref == NULL) {
313  m_TheLandscape->Warn("TPredator_Population_Manager::PredSampleFile","Could Not Open PredSampleData.txt File");
314  exit(0);
315  }
316 
317  Owl* Op;
318  unsigned int SizeOwl = (unsigned int) TheArray[1].size();
319  unsigned int TotalSize = SizeOwl;
322  fprintf(pref,"%d\t %d\t %d\t %d\t %u\t %u\n", 0,w ,0, h, SizeOwl, TotalSize);
323 
324  for (unsigned i = 0; i < SizeOwl; i++){
325  Op=dynamic_cast<Owl*>(TheArray[1][i]);
326  int Wx = Op->Supply_m_Location_x();
327  int Wy = Op->Supply_m_Location_y();
328  int Wpoly = m_TheLandscape->SupplyPolyRef(Wx, Wy);
329  int Wele = m_TheLandscape->SupplyElementType(Wpoly);
330  int Wveg = m_TheLandscape->SupplyVegType(Wpoly);
331 
332  int Wspecies = Op->SupplySpeciesID();
333  int Wkill = Op->SupplyKill();
334  int WKillEff = Op->SupplyKillEff();
335  int Terr = Op->SupplyTerr();
336  int HomeR = Op->SupplyHomeRange();
337 
338  fprintf(pref,"%d\t",year);
339  fprintf(pref,"%d\t",month);
340  fprintf(pref,"%d\t",dayinMo);
341  fprintf(pref,"%d\t",today);
342 
343  fprintf(pref,"%d\t",Wspecies);
344  fprintf(pref,"%d\t",Wkill);
345  fprintf(pref,"%d\t",WKillEff);
346  fprintf(pref,"%d\t",Terr);
347  fprintf(pref,"%d\t",HomeR);
348 
349  fprintf(pref,"%d\t",Wx);
350  fprintf(pref,"%d\t",Wy);
351  fprintf(pref,"%d\t",Wpoly);
352  fprintf(pref,"%d\t",Wele);
353  fprintf(pref,"%d\t",Wveg);
354  fprintf(pref,"\n");
355  }
356  fclose(pref);
357  }
358 }
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
int SupplyDayInMonth(void)
Definition: landscape.h:1606
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1488
TTypesOfVegetation SupplyVegType(int a_x, int a_y)
Definition: landscape.h:1321
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
int SupplyMonth(void)
Definition: landscape.h:1601
int Supply_m_Location_x()
Definition: PopulationManager.h:213
int Supply_m_Location_y()
Definition: PopulationManager.h:216
int SupplyHomeRange()
Definition: Predators.h:138
int SupplyKill()
Definition: Predators.h:135
int SupplyKillEff()
Definition: Predators.h:137
bool SupplyTerr()
Definition: Predators.h:136
unsigned SupplySpeciesID()
Definition: Predators.h:134

References cfg_owl_StartingNo, cfg_weasel_StartingNo, Population_Manager::m_TheLandscape, TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Landscape::SupplyDayInMonth(), Landscape::SupplyDayInYear(), Landscape::SupplyElementType(), TPredator::SupplyHomeRange(), TPredator::SupplyKill(), TPredator::SupplyKillEff(), Landscape::SupplyMonth(), Landscape::SupplyPolyRef(), Landscape::SupplySimAreaHeight(), Landscape::SupplySimAreaWidth(), TPredator::SupplySpeciesID(), TPredator::SupplyTerr(), Landscape::SupplyVegType(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, CfgInt::value(), and Landscape::Warn().

Referenced by Run().

◆ PredSpringAutumnSample()

void TPredator_Population_Manager::PredSpringAutumnSample ( )
protected
487 {
488  int today = m_TheLandscape->SupplyDayInYear();
489  int year = m_TheLandscape->SupplyYearNumber();
490 
492  unsigned int SizeWeasel = (unsigned int) TheArray[0].size();
493  unsigned int SizeOwl = (unsigned int) TheArray[1].size();
494  unsigned int TotalSize = SizeWeasel+SizeOwl;
495 
496  FILE* pref=fopen("PredSpringAutumnOutput.txt","a");
497  if (pref == NULL) {
498  m_TheLandscape->Warn("TPredator_Population_Manager::PredSpringAutumnSample","Could Not Open PredSpringAutumnOutput.txt File");
499  exit(0);
500  }
501 
502  fprintf(pref,"%d\t", year);
503  fprintf(pref,"%d\t", today);
504  fprintf(pref,"%d\t", SizeWeasel);
505  fprintf(pref,"%d\t", SizeOwl);
506  fprintf(pref,"%d\t", TotalSize);
507  fprintf(pref,"\n");
508 
509  fclose(pref);
510  }
511 
512  else if (cfg_weasel_StartingNo.value()> 0){
513  unsigned int SizeWeasel = (unsigned int) TheArray[0].size();
514 
515  FILE* pref=fopen("PredSpringAutumnOutput.txt","a");
516  if (pref == NULL) {
517  m_TheLandscape->Warn("TPredator_Population_Manager::PredSpringAutumnSample","Could Not Open PredSpringAutumnOutput.txt File");
518  exit(0);
519  }
520  fprintf(pref,"%d\t", year);
521  fprintf(pref,"%d\t", today);
522  fprintf(pref,"%d\t", SizeWeasel);
523  fprintf(pref,"%d\t", 0);
524  fprintf(pref,"%d\t", SizeWeasel);
525  fprintf(pref,"\n");
526 
527  fclose(pref);
528  }
529  else if (cfg_owl_StartingNo.value()> 0) {
530  unsigned int SizeOwl = (unsigned int) TheArray[1].size();
531 
532  FILE* pref=fopen("PredSpringAutumnOutput.txt","a");
533  if (pref == NULL) {
534  m_TheLandscape->Warn("TPredator_Population_Manager::PredSpringAutumnSample","Could Not Open PredSpringAutumnOutput.txt File");
535  exit(0);
536  }
537  fprintf(pref,"%d\t", year);
538  fprintf(pref,"%d\t", today);
539  fprintf(pref,"%d\t", 0);
540  fprintf(pref,"%d\t", SizeOwl);
541  fprintf(pref,"%d\t", SizeOwl);
542  fprintf(pref,"\n");
543 
544  fclose(pref);
545  }
546 }

References cfg_owl_StartingNo, cfg_weasel_StartingNo, Population_Manager::m_TheLandscape, Landscape::SupplyDayInYear(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, CfgInt::value(), and Landscape::Warn().

Referenced by Run().

◆ PredSpringSample()

void TPredator_Population_Manager::PredSpringSample ( )
protected
424 {
425  int today = m_TheLandscape->SupplyDayInYear();
426  int year = m_TheLandscape->SupplyYearNumber();
427 
429  unsigned int SizeWeasel = (unsigned int) TheArray[0].size();
430  unsigned int SizeOwl = (unsigned int) TheArray[1].size();
431  unsigned int TotalSize = SizeWeasel+SizeOwl;
432 
433  FILE* pref=fopen("PredSpringOutput.txt","a");
434  if (pref == NULL) {
435  m_TheLandscape->Warn("TPredator_Population_Manager::PredSpringSample","Could Not Open PredSpringOutput.txt File");
436  exit(0);
437  }
438  fprintf(pref,"%d\t", year);
439  fprintf(pref,"%d\t", today);
440  fprintf(pref,"%d\t", SizeWeasel);
441  fprintf(pref,"%d\t", SizeOwl);
442  fprintf(pref,"%d\t", TotalSize);
443  fprintf(pref,"\n");
444 
445  fclose(pref);
446  }
447 
448  else if (cfg_weasel_StartingNo.value()> 0){
449  unsigned int SizeWeasel = (unsigned int) TheArray[0].size();
450 
451  FILE* pref=fopen("PredSpringOutput.txt","a");
452  if (pref == NULL) {
453  m_TheLandscape->Warn("TPredator_Population_Manager::PredSpringSample","Could Not Open PredSpringOutput.txt File");
454  exit(0);
455  }
456  fprintf(pref,"%d\t", year);
457  fprintf(pref,"%d\t", today);
458  fprintf(pref,"%d\t", SizeWeasel);
459  fprintf(pref,"%d\t", 0);
460  fprintf(pref,"%d\t", SizeWeasel);
461  fprintf(pref,"\n");
462 
463  fclose(pref);
464  }
465 
466  else if (cfg_owl_StartingNo.value()> 0) {
467  unsigned int SizeOwl = (unsigned int) TheArray[1].size();
468 
469  FILE* pref=fopen("PredSpringOutput.txt","a");
470  if (pref == NULL) {
471  m_TheLandscape->Warn("TPredator_Population_Manager::PredSpringSample","Could Not Open PredSpringOutput.txt File");
472  exit(0);
473  }
474  fprintf(pref,"%d\t", year);
475  fprintf(pref,"%d\t", today);
476  fprintf(pref,"%d\t", 0);
477  fprintf(pref,"%d\t", SizeOwl);
478  fprintf(pref,"%d\t", SizeOwl);
479  fprintf(pref,"\n");
480 
481  fclose(pref);
482  }
483 }

References cfg_owl_StartingNo, cfg_weasel_StartingNo, Population_Manager::m_TheLandscape, Landscape::SupplyDayInYear(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, CfgInt::value(), and Landscape::Warn().

Referenced by Run().

◆ Run()

void TPredator_Population_Manager::Run ( int  NoTSteps)
virtual

This is the main scheduling method for the population manager.
Note the structure of Shuffle_or_Sort(), DoFirst(), BeginStep, DoBefore(), Step looping until all are finished, DoAfter(), DoAlmostLast(), EndStep, DoLast().

Can do multiple time-steps here inside one landscape time-step (a day). This is used in the roe deer model to provide 10 minute behavioural time-steps.

It is necessary to remove any dead animals before the timestep starts. It is possible that animals are killed after their population manager Run method has been executed. This is the case with geese and hunters. Checking death first prevents this becomming a problem.

Reimplemented from Population_Manager.

554 {
555  DoFirst();
556  // begin step actions ...
557  // set all stepdone to false.... is this really necessary??
558  int today = m_TheLandscape->SupplyDayInYear();
560 
563  {
564  PredSampleFile();
566  }
567  if (today == cfg_pred_first_sample_day.value())
568  {
570  }
571  if (today == cfg_pred_second_sample_day.value())
572  {
574  }
575  }
576 
577  if (today==364 ) {
578  FILE* pref = fopen("PredProbe.txt","a");
579  if (!pref) {
580  m_TheLandscape->Warn("Predator_Population_Manager Destructor","Could Not Open PredProbe.txt File");
581  exit(0);
582  }
583  if ((TheArray[0].size()> 0)&& (TheArray[1].size()> 0)){
584  unsigned int PredNo0 = (unsigned int) TheArray[0].size();
585  unsigned int PredNo1 = (unsigned int) TheArray[1].size();
586  fprintf(pref,"%d\t%u\t%u\t%u\t%u\n", Y, 0, PredNo0, 1, PredNo1);
587  }
588  else if (TheArray[0].size()> 0){
589  unsigned int PredNo0 = (unsigned int) TheArray[0].size();
590  fprintf(pref,"%d\t%u\t%u\n", Y, 0, PredNo0);
591  }
592  else if (TheArray[1].size()> 0) {
593  unsigned int PredNo1 = (unsigned int) TheArray[1].size();
594  fprintf(pref,"%d\t%u\t%u\n", Y, 1, PredNo1);
595  }
596  fclose(pref);
597  }
598 // cal
599  for (unsigned listindex=0; listindex<TheArray.size(); listindex++)
600  {
601  for (unsigned j=0; j<TheArray[listindex].size(); j++)
602  {
603  TheArray[listindex][j]->SetStepDone(false);
604  }
605  }
606  // call the begin-step-method of all objects
607  for (unsigned listindex=0; listindex<TheArray.size();listindex++)
608  {
609  for (unsigned j=0; j<TheArray[listindex].size(); j++)
610  TheArray[listindex][j]->BeginStep();
611  }
612  DoBefore();
613  // call the step-method of all objects
614  do
615  {
616  for (unsigned listindex=0; listindex<TheArray.size();listindex++)
617  {
618  for (unsigned j=0; j<TheArray[listindex].size(); j++)
619  {
620  TheArray[listindex][j]->Step();
621  }
622  } // for listindex
623  } while (!StepFinished());
624  DoAfter();
625  // call the end-step-method of all objects
626  for (unsigned listindex=0; listindex<TheArray.size();listindex++)
627  {
628  for (unsigned j=0; j<TheArray[listindex].size(); j++)
629  {
630  TheArray[listindex][j]->EndStep();
631  }
632  }
633  // ----------------
634  // end of this step actions
635 
636  // For each animal list
637  for (unsigned listindex=0; listindex<TheArray.size();listindex++)
638  {
639  // Must check each object in the list for m_CurrentStateNo==-1
640  int TAend=(int)TheArray[listindex].size()-1;
641  for (int j=TAend; j>=0; j--) // Search backwards is more efficicent
642  {
643  if (TheArray[listindex][j]->GetCurrentStateNo() == -1) // code for kill it
644  {
645  delete TheArray[listindex][j];
646  TheArray[listindex].erase(TheArray[listindex].begin()+j);
647  }
648  }
649  }
650  DoLast();
651 }
static CfgBool cfg_PredSampleDataUsed("PRED_SAMPLE_DATA_USED", CFG_CUSTOM, false)
static CfgInt cfg_pred_second_sample_day("PRED_SAMPLE_FILE_DAY_TWO", CFG_CUSTOM, 287)
static CfgInt cfg_pred_first_sample_day("PRED_SAMPLE_FILE_DAY_ONE", CFG_CUSTOM, 109)
bool value(void)
Definition: configurator.h:135
virtual void DoLast()
Definition: Predators.h:170
void PredSpringSample()
Definition: Predators.cpp:423
virtual bool StepFinished()
Overrides the population manager StepFinished - there is no chance that hunters do not finish a step ...
Definition: Predators.cpp:655
virtual void DoAfter()
Definition: Predators.h:169
virtual void DoBefore()
Definition: Predators.h:168
void PredAutumnSample()
Definition: Predators.cpp:360
void PredSpringAutumnSample()
Definition: Predators.cpp:486
virtual void DoFirst()
Definition: Predators.h:167
void PredSampleFile()
Definition: Predators.cpp:161

References cfg_pred_first_sample_day, cfg_pred_second_sample_day, cfg_PredSampleDataUsed, DoAfter(), DoBefore(), DoFirst(), DoLast(), Population_Manager::m_TheLandscape, PredAutumnSample(), PredSampleFile(), PredSpringAutumnSample(), PredSpringSample(), StepFinished(), Landscape::SupplyDayInYear(), Landscape::SupplyYearNumber(), Population_Manager::TheArray, CfgInt::value(), CfgBool::value(), and Landscape::Warn().

Referenced by RunTheSim().

◆ StepFinished()

bool TPredator_Population_Manager::StepFinished ( void  )
protectedvirtual

Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour.

Returns true if and only if all objects have finished the current step

Reimplemented from Population_Manager.

656 {
657  for (unsigned listindex=0; listindex<TheArray.size();listindex++)
658  {
659  for (unsigned j=0; j<TheArray[listindex].size(); j++)
660  {
661  if (TheArray[listindex][j]->GetStepDone() == false)
662  {
663  return false;
664  }
665  }
666  }
667  return true;
668 }

References Population_Manager::TheArray.

Referenced by Run().

◆ supply_no_inds()

unsigned TPredator_Population_Manager::supply_no_inds ( unsigned  list)
inline
157 {return m_no_individuals[list];}

References m_no_individuals.

Referenced by Weasel::BeginStep(), and Owl::BeginStep().

Member Data Documentation

◆ m_no_individuals

unsigned TPredator_Population_Manager::m_no_individuals[2]
protected

◆ m_Prey

Vole_Population_Manager* TPredator_Population_Manager::m_Prey
protected

◆ NoPredatorTypes

unsigned TPredator_Population_Manager::NoPredatorTypes
protected

The documentation for this class was generated from the following files: